package my.maven.project.common.redis;

  
import redis.clients.jedis.Jedis;
import org.springframework.util.StringUtils;
 
/**
 * 消息发布方
 * @author yamikaze
 */
public class Publisher {
 
    public static final String CHANNEL_KEY = "channel:message";
    private Jedis jedis;
 
    public Publisher() {
        jedis = RedisUtils.getJedis();
    }
 
    public void publishMessage(String message) {
        if(StringUtils.isEmpty(message)) {
            return;
        }
        jedis.publish(CHANNEL_KEY, message);
    }
 
    public static void main(String[] args) {
        Publisher publisher = new Publisher();
        publisher.publishMessage("Hello Redis!");
    }
} 